package com.example.springbootdemo.beanpostprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class CustomBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(Test.class.equals(bean.getClass())) {
            System.out.println("执行自定义postProcessBeforeInitialization");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(Test.class.equals(bean.getClass())) {
            System.out.println("执行自定义postProcessAfterInitialization");
        }
        return bean;
    }
}
